<template>
  <div>
    <!-- 二级路由出口 -->
    <keep-alive>
      <router-view class="view"></router-view>
    </keep-alive>
    <!-- 底部导航 -->
    <footer class="footer">
      <router-link v-for="item in arr" :key="item.path" :to="item.path" active-class="select">
        <img :src="$route.path===item.path?item.select_img:item.no_select" alt="">
        <div>{{item.name}}</div>
      </router-link>
    </footer>
  </div>
</template>

<script>
import home_y from "../../assets/img/home_y.jpeg";
import home_n from "../../assets/img/home_n.jpeg";
import cate_y from "../../assets/img/cate_y.jpeg";
import cate_n from "../../assets/img/cate_n.jpeg";
import shop_y from "../../assets/img/shop_y.jpeg";
import shop_n from "../../assets/img/shop_n.jpeg";
import mine_y from "../../assets/img/mine_y.jpeg";
import mine_n from "../../assets/img/mine_n.jpeg";
export default {
  data() {
    return {
      arr: [
        {
          path: "/index/home",
          name: "首页",
          select_img: home_y,
          no_select: home_n,
        },
        {
          path: "/index/cate",
          name: "分类",
          select_img: cate_y,
          no_select: cate_n,
        },
        {
          path: "/index/shop",
          name: "购物车",
          select_img: shop_y,
          no_select: shop_n,
        },
        {
          path: "/index/mine",
          name: "我的",
          select_img: mine_y,
          no_select: mine_n,
        },
      ],
    };
  },
};
</script>

<style scoped>
.view {
  padding-bottom: 0.8rem;
}
.footer{
  height: 1rem;
  position: fixed;
  width: 100vw;
  background: #fff;
  left: 0;
  bottom: 0;
  border-top: 0.01rem solid #ccc;
  display: flex;
}
.footer a{
  flex: 1;
  text-align: center;
  padding-top: 0.1rem;
}
.footer a img{
  width: 0.5rem;
  height: 0.5rem;
}
.footer a div{
  font-size: 0.24rem;
  line-height: 0.5rem;
  color:#333;
}
.footer .select div{
  color: #ff4400;
}
</style>
